package com.itheima.stock.Thread;

public class SetDeamon {
    public static void main(String[] args) {
        /*
        void setDaemon(boolean on)
        当非守护线程都运行完毕后，守护线程也会陆续结束
         */
        MyThread1 t1 = new MyThread1();
        MyThread2 t2 = new MyThread2();

        t1.setName("女神出现第");
        t2.setName("舔狗出现第");

        //把备胎设置为守护线程 女神不在了备胎差不多也没必要存在了
        t2.setDaemon(true); //当t1运行完毕后，t2也会陆续结束

        t1.start();
        t2.start();
    }




}
class MyThread1 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(getName() + i + "次");
        }
    }
}


class MyThread2 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(getName() + i + "次");
        }
    }
}
